/*  Copyright (c) 2004-2006 Srichand Pendyala <srichand.pendyala@gmail.com>
 *  sharpscoreglade.cs - This file is part of Sharpscore.
 *
 *  Sharpscore is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  Sharpscore is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Sharpscore; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

using System;
using System.Timers;
using Gtk;
using GtkSharp;
using Glade;
using Scorethingy;

class SharpScoreGlade{
	Score sc;
	Timer t1;
	public static void Main(string[] args){
		new SharpScoreGlade();
	}
	[Glade.WidgetAttribute]
	Gtk.Label playing, match, mainscore, date;
	public SharpScoreGlade(){
		Application.Init();
		Glade.XML gxml = new Glade.XML("sharpscore.glade", "window1", null);
		gxml.Autoconnect(this);
		sc = new Score();
		RefreshScore(this, new EventArgs());
		t1 = new Timer(60*1000); //FIXME: Urghh! Hard coded values!
		t1.Elapsed += new ElapsedEventHandler(RefreshScore);
		t1.Enabled = true;
		GC.KeepAlive(t1);
		Application.Run();
	}

	public static void on_window1_delete_event(System.Object obj, DeleteEventArgs arg){
		Application.Quit();
	}

	public void RefreshScore(System.Object obj, EventArgs args ){
		playing.Text = "Refreshing";
		sc.GetScore();
		playing.Text = sc.NowPlaying;
		match.Text = sc.Match;
		mainscore.Text = sc.FinalScore;
		date.Text = sc.date;
	}
}
